package com.example.demo.程序员面试金典;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: TODO
 * @author: zhangzc
 * @modified By: zhangzc
 * @date: Created in 2022/9/8 14:49
 * @version:v1.0
 */
public class 幂集 {

	//todo todo
	class Solution {

		private List<List<Integer>> ans;
		private int[] nums;

		public List<List<Integer>> subsets(int[] nums) {
			ans = new ArrayList<>();
			this.nums = nums;
			dfs(0, new ArrayList<>());
			return ans;
		}

		private void dfs(int u, List<Integer> t) {
			if (u == nums.length) {
				ans.add(new ArrayList<>(t));
				return;
			}
			t.add(nums[u]);
			dfs(u + 1, t);
			t.remove(t.size() - 1);
			dfs(u + 1, t);
		}
	}

}
